home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / as2db1 / globals.bas < prev    next >
BASIC Source File  |  1994-01-01  |  10KB  |  284 lines

  1. Option Explicit
  2.  
  3. '---asc2mdb converter
  4. '---standard application globals
  5.  
  6. Dim c$              'receives currency str, e.g. "$"
  7. Dim M$              'receives thousands str, e.g. ","
  8.     
  9. Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer) As Integer
  10.  
  11. Global ReplaceMode As Integer
  12. '     ReplaceMode is initialized in project .BAS file,
  13. '     Sub SetupSpecifics.  Can't be a constant, since
  14. '     it can be changed at runtime with radio button.
  15.  
  16. Global ReplaceModes() As String
  17. 'strings to describe each replace mode
  18.  
  19. Global ProgramEdit As Integer ' boolean to distinguish
  20.         'betw user click and program induced click
  21.  
  22. Global thisDb As database   'global may be overridden
  23.     
  24. Global Ans              'response to message box
  25.  
  26. Global NL As String
  27.  
  28. Global gbErrorLimit     'sets limit for error reporting
  29.  
  30. Type IOFieldType
  31.     dbName As String
  32.     dbSize As Long
  33.     dbType As Integer
  34.     inStart As Integer
  35.     inLength As Integer
  36.     value As Variant
  37. End Type
  38.  
  39. Type IndexPtrnType
  40.     Name As String
  41.     Fields As String
  42.     Primary As Integer
  43.     Unique As Integer
  44. End Type
  45.  
  46. Global gIOFld() As IOFieldType      'input fields defined above
  47. Global gIndexPtrn() As IndexPtrnType
  48.  
  49. Global gTabOut As table
  50. Global gRunning As Integer
  51.  
  52.  
  53. 'File Open/Save Dialog Flags
  54. Global Const OFN_READONLY = &H1&
  55. Global Const OFN_OVERWRITEPROMPT = &H2&
  56. Global Const OFN_HIDEREADONLY = &H4&
  57. Global Const OFN_NOCHANGEDIR = &H8&
  58. Global Const OFN_SHOWHELP = &H10&
  59. Global Const OFN_NOVALIDATE = &H100&
  60. Global Const OFN_ALLOWMULTISELECT = &H200&
  61. Global Const OFN_EXTENSIONDIFFERENT = &H400&
  62. Global Const OFN_PATHMUSTEXIST = &H800&
  63. Global Const OFN_FILEMUSTEXIST = &H1000&
  64. Global Const OFN_CREATEPROMPT = &H2000&
  65. Global Const OFN_SHAREAWARE = &H4000&
  66. Global Const OFN_NOREADONLYRETURN = &H8000&
  67.  
  68. Global Const KEY_RETURN = &HD
  69.  
  70.  
  71. '
  72. ' Data Access constants
  73. '
  74.  
  75. ' Option argument values (CreateDynaset, etc)
  76. Global Const DB_DENYWRITE = &H1
  77. Global Const DB_DENYREAD = &H2
  78. Global Const DB_READONLY = &H4
  79. Global Const DB_APPENDONLY = &H8
  80. Global Const DB_INCONSISTENT = &H10
  81. Global Const DB_CONSISTENT = &H20
  82. Global Const DB_SQLPASSTHROUGH = &H40
  83.  
  84. ' SetDataAccessOption
  85. Global Const DB_OPTIONINIPATH = 1
  86.  
  87. ' Field Attributes
  88. Global Const DB_FIXEDFIELD = &H1
  89. Global Const DB_VARIABLEFIELD = &H2
  90. Global Const DB_AUTOINCRFIELD = &H10
  91. Global Const DB_UPDATABLEFIELD = &H20
  92.  
  93. ' Field Data Types
  94. Global Const DB_BOOLEAN = 1
  95. Global Const DB_BYTE = 2
  96. Global Const DB_INTEGER = 3
  97. Global Const DB_LONG = 4
  98. Global Const DB_CURRENCY = 5
  99. Global Const DB_SINGLE = 6
  100. Global Const DB_DOUBLE = 7
  101. Global Const DB_DATE = 8
  102. Global Const DB_TEXT = 10
  103. Global Const DB_LONGBINARY = 11
  104. Global Const DB_MEMO = 12
  105.  
  106. ' TableDef Attributes
  107. Global Const DB_ATTACHEXCLUSIVE = &H10000
  108. Global Const DB_ATTACHSAVEPWD = &H20000
  109. Global Const DB_SYSTEMOBJECT = &H80000002
  110. Global Const DB_ATTACHEDTABLE = &H40000000
  111. Global Const DB_ATTACHEDODBC = &H20000000
  112.  
  113. ' ListTables TableType
  114. Global Const DB_TABLE = 1
  115. Global Const DB_QUERYDEF = 5
  116.  
  117. ' ListTables Attributes (for QueryDefs)
  118. Global Const DB_QACTION = &HF0
  119. Global Const DB_QCROSSTAB = &H10
  120. Global Const DB_QDELETE = &H20
  121. Global Const DB_QUPDATE = &H30
  122. Global Const DB_QAPPEND = &H40
  123. Global Const DB_QMAKETABLE = &H50
  124.  
  125. ' ListIndexes IndexAttributes values
  126. Global Const DB_UNIQUE = 1
  127. Global Const DB_PRIMARY = 2
  128. Global Const DB_PROHIBITNULL = 4
  129. Global Const DB_IGNORENULL = 8
  130. ' ListIndexes FieldAttributes value
  131. Global Const DB_DESCENDING = 1  'For each field in Index
  132.  
  133. ' CreateDatabase and CompactDatabase Language constants
  134. Global Const DB_LANG_GENERAL = ";LANGID=0x0809;CP=1252;COUNTRY=0"
  135. Global Const DB_LANG_SPANISH = ";LANGID=0x040A;CP=1252;COUNTRY=0"
  136. Global Const DB_LANG_DUTCH = ";LANGID=0x0413;CP=1252;COUNTRY=0"
  137. Global Const DB_LANG_SWEDFIN = ";LANGID=0x040C;CP=1252;COUNTRY=0"   'VB3 and Access 1.1 Databases
  138. Global Const DB_LANG_NORWDAN = ";LANGID=0x0414;CP=1252;COUNTRY=0"   'VB3 and Access 1.1 Databases
  139. Global Const DB_LANG_ICELANDIC = ";LANGID=0x040F;CP=1252;COUNTRY=0" 'VB3 and Access 1.1 Databases
  140. Global Const DB_LANG_NORDIC = ";LANGID=0x041D;CP=1252;COUNTRY=0"    'Access 1.0 Databases only
  141.  
  142. ' CreateDatabase and CompactDatabase options
  143. Global Const DB_VERSION10 = 1        ' Microsoft Access Version 1.0
  144. Global Const DB_ENCRYPT = 2          ' Make database encrypted.
  145. Global Const DB_DECRYPT = 4          ' Decrypt database while compacting.
  146.  
  147. 'Collating order values
  148. Global Const DB_SORTGENERAL = 256    ' Sort by EFGPI rules (English, French, German,Portuguese, Italian)
  149. Global Const DB_SORTSPANISH = 258    ' Sort by Spanish rules
  150. Global Const DB_SORTDUTCH = 259      ' Sort by Dutch rules
  151. Global Const DB_SORTSWEDFIN = 260    ' Sort by Swedish, Finnish rules
  152. Global Const DB_SORTNORWDAN = 261    ' Sort by Norwegian, Danish rules
  153. Global Const DB_SORTICELANDIC = 262  ' Sort by Icelandic rules
  154. Global Const DB_SORTPDXINTL = 4096   ' Sort by Paradox international rules
  155. Global Const DB_SORTPDXSWE = 4097    ' Sort by Paradox Swedish, Finnish rules
  156. Global Const DB_SORTPDXNOR = 4098    ' Sort by Paradox Norwegian, Danish rules
  157. Global Const DB_SORTUNDEFINED = -1   ' Sort rules are undefined or unknown
  158.  
  159. ' Function Parameters
  160. ' MsgBox parameters
  161. Global Const MB_OK = 0                 ' OK button only
  162. Global Const MB_OKCANCEL = 1           ' OK and Cancel buttons
  163. Global Const MB_ABORTRETRYIGNORE = 2   ' Abort, Retry, and Ignore buttons
  164. Global Const MB_YESNOCANCEL = 3        ' Yes, No, and Cancel buttons
  165. Global Const MB_YESNO = 4              ' Yes and No buttons
  166. Global Const MB_RETRYCANCEL = 5        ' Retry and Cancel buttons
  167.  
  168. Global Const MB_ICONSTOP = 16          ' Critical message
  169. Global Const MB_ICONQUESTION = 32      ' Warning query
  170. Global Const MB_ICONEXCLAMATION = 48   ' Warning message
  171. Global Const MB_ICONINFORMATION = 64   ' Information message
  172.  
  173. Global Const MB_APPLMODAL = 0          ' Application Modal Message Box
  174. Global Const MB_DEFBUTTON1 = 0         ' First button is default
  175. Global Const MB_DEFBUTTON2 = 256       ' Second button is default
  176. Global Const MB_DEFBUTTON3 = 512       ' Third button is default
  177. Global Const MB_SYSTEMMODAL = 4096      'System Modal
  178.  
  179. ' MsgBox return values
  180. Global Const IDOK = 1                  ' OK button pressed
  181. Global Const IDCANCEL = 2              ' Cancel button pressed
  182. Global Const IDABORT = 3               ' Abort button pressed
  183. Global Const IDRETRY = 4               ' Retry button pressed
  184. Global Const IDIGNORE = 5              ' Ignore button pressed
  185. Global Const IDYES = 6                 ' Yes button pressed
  186. Global Const IDNO = 7                  ' No button pressed
  187.  
  188. Sub GlobalInit ()
  189.     SvcCurrProfile c$, M$
  190.     ReplaceModeTextStrings
  191.     gbErrorLimit = 50
  192. End Sub
  193.  
  194. Sub ReplaceModeTextStrings ()
  195.   ReDim ReplaceModes(0 To 5)
  196.  
  197.   ReplaceModes(0) = "&0- Delete old db; recreate db and table"
  198.   ReplaceModes(1) = "&1- Keep old db; recreate the table"
  199.   ReplaceModes(2) = "&2- Keep old db; add new records to table"
  200.   ReplaceModes(3) = "&3- Mass delete and add per input criteria"
  201.   ReplaceModes(4) = "&4- Individual record replace; if nomatch, add new"
  202.   ReplaceModes(5) = "&5- Field Update; if nomatch; log an error"
  203.  
  204. End Sub
  205.  
  206. Private Sub SvcCurrProfile (c$, M$)
  207.     ' get the win.ini defaults for
  208.     ' C$ currency symbol (def "$")
  209.     ' M$ thousands separator (def ",")
  210.     
  211.     ' api call stuff
  212.     
  213.     Const App$ = "intl"
  214.     
  215.     Const CKey$ = "sCurrency"
  216.     Const CDef$ = "Y"
  217.     Dim CBuf$           'return buffer for C$
  218.     CBuf$ = Space$(128)
  219.     Dim CLen%
  220.     CLen% = Len(CBuf$)
  221.     
  222.     Const MKey$ = "sThousand"
  223.     Const MDef$ = "."
  224.     Dim MBuf$           'return buffer for M$
  225.     MBuf$ = Space$(128)
  226.     Dim MLen%
  227.     MLen% = Len(MBuf$)
  228.     
  229.     Dim ret%
  230.  
  231.     ret% = GetProfileString(App$, CKey$, CDef$, CBuf$, CLen%)
  232.     c$ = Left$(CBuf$, ret%)
  233.     
  234.     ret% = GetProfileString(App$, MKey$, MDef$, MBuf$, MLen%)
  235.     M$ = Left$(MBuf$,